/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mb.webserver.handler;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import mb.config.Constants;

/**
 *
 * @author thanh.nguyenchi
 */
public class HomePage extends  BaseServlet{
    private String fileSeparator;
    private String homeFile;
    
    public HomePage(){
        super();
        fileSeparator = System.getProperty("file.separator");
        homeFile = System.getProperty("user.dir") + fileSeparator + Constants.STR_WEBSERVER_ROOT + fileSeparator + Constants.STR_WEBSERVER_HOMEPAGE;
    }
    
    @Override
    public void doGet(HttpServletRequest request,HttpServletResponse response)
            throws ServletException,IOException
    {             
        log("[HomePage] dir = " + homeFile);
        String sOut = fetch(homeFile);
        response.setContentType("text/html");
        response.setStatus(HttpServletResponse.SC_OK);
        response.getWriter().println(sOut);
    }    
}
